{% load static %}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>好看的双栏博客</title>
    <link href="../static/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="../static/css/cl-css.css" rel="stylesheet">
    <link href="../static/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <link rel="stylesheet" href="../static/highlight/styles/railscasts.css">
    <style type="text/css">


        .aa{
            width: 100%;
            height: 100%;
        }
    </style>
</head>
<body>
<div class="cl-header container-fluid" id="app">
    <div class="header-content container">
        <nav class="navbar navbar-expand-lg navbar-light">
            <a class="navbar-brand" href="/">
                <img src="../static/img/logo.jpeg" width="144" height="72" alt="">
            </a>
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav"
                    aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse justify-content-end" id="navbarNav">
                <ul class="navbar-nav">
                    <li >
                        <a class="nav-link" href="{% url 'home:index' %}">首页</a>
                    </li>
                    {#分类#}
                    {% for cat in categories %}
                        {% if cat.id == category.id %}
                            <li class="nav-item active">
                                <a class="nav-link" href="/?cat_id={{ cat.id }}">{{ cat.title }}</a>
                            </li>
                        {% else %}
                            <li class="nav-item">
                                <a class="nav-link" href="/?cat_id={{ cat.id }}">{{ cat.title }}</a>
                            </li>
                        {% endif %}
                    {% endfor %}

                    <!-- 如果用户已经登录，则显示用户名下拉框 -->
                    <li class="nav-item dropdown" v-if="is_login">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button"
                           data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" @click="show_menu_click">{{ username }}</a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdown" style="display: block"
                             v-show="show_menu">
                            <a class="dropdown-item" href="{% url 'users:writeblog' %}">写文章</a>
                            <a class="dropdown-item" href='{% url 'users:usercenter' %}'>个人信息</a>
                            <a class="dropdown-item" href='{% url 'users:logout' %}'>退出登录</a>
                        </div>
                    </li>
                    <!-- 如果用户未登录，则显示登录按钮 -->
                    <li class="nav-item" v-else>
                        <a class="nav-link" href="{% url 'users:login' %}">登录</a>
                    </li>

                </ul>
            </div>
        </nav>
    </div>
</div>

<div class="cl-cantainer container">
    <div class="row">
        <div class="col-md-9 cl-left">
            {% block advert %}
            {% endblock %}

            {% block relevant %}
            {% endblock %}


            {% block nei %}
            {% endblock %}

            <nav aria-label="Page navigation example">
                <ul class="pagination justify-content-center">
                    {# has_previous True如果有上一页，则返回#}
                    {% if articles.has_previous %}
                        <li class="page-item">
                            <a class="page-link"
                               href="?cat_id={{ cat_id }}&page_index={{ articles.previous_page_number }}"
                               aria-label="Previous">
                                <span aria-hidden="true">上一页</span>
                                <span class="sr-only">上一页</span>
                            </a>
                        </li>
                    {% else %}
                        <li class="page-item disabled">
                            <a class="page-link" href="#" aria-label="Previous">
                                <span aria-hidden="true">上一页</span>
                                <span class="sr-only">上一页</span>
                            </a>
                        </li>
                    {% endif %}
                    {#  articles.paginator.page_range  返回当前数据的 页码迭代器。 #}
                    {% for num in articles.paginator.page_range %}
                        {% if num %}
                            {% ifequal num articles.number %}
                                <li class="page-item active"><a class="page-link" href="#">{{ num }}</a></li>
                            {% else %}
                                <li class="page-item"><a class="page-link"
                                                         href="?cat_id={{ cat_id }}&page_index={{ num }}">{{ num }}</a>
                                </li>
                            {% endifequal %}
                        {% else %}
                            <li class="disabled"><a href="#">...</a></li>
                        {% endif %}
                    {% endfor %}
                    {# has_next True如果有下一页则返回#}
                    {% if articles.has_next %}
                        <li class="page-item">
                            <a class="page-link"
                               href="?cat_id={{ cat_id }}&page_index={{ articles.next_page_number }}"
                               aria-label="Next">
                                <span aria-hidden="true">下一页</span>
                                <span class="sr-only">下一页</span>
                            </a>
                        </li>
                    {% else %}
                        <li class="page-item disabled">
                            <a class="page-link" href="#" aria-label="Next">
                                <span aria-hidden="true">下一页</span>
                                <span class="sr-only">下一页</span>
                            </a>
                        </li>
                    {% endif %}
                    <li class="page-item disabled">
                        <a href="#" class="page-link">共计：{{ articles.paginator.count }} 条</a>
                    </li>
                </ul>
            </nav>
        </div>
        <div class="col-md-3 cl-right">
            <div class="right-card">

                <div class="right-card-main">
                    <div class="right-card-title">若您被侵权，请联系</div>
                    <div class="cl-code">
                        <img src="../static/img/comp.jpeg" class="img-fluid" alt="">
                        <p>关注作者获取更多模板信息，定时发布干货文章</p>
                    </div>
                </div>
            </div>

            <div class="right-card">

                <div class="right-card-main">
                    <div class="right-card-title">最新文章</div>

                    {% for new_artcle in news_artcle %}

                    <ul class="right-recommended-list">
                        <li>
                            <a href="{% url 'home:detail' %}?art_id={{ new_artcle.id }}">
                                <i class="fa fa-angle-right" aria-hidden="true">

                                </i>{{ new_artcle.title }}
                            </a>
                        </li>
                    </ul>
                    {% endfor %}
                </div>
            </div>

            <div class="right-card">

                <div class="right-card-main">
                    <div class="right-card-title">热门标签</div>
                    <ul class="label">
                    {% for hot_tag in hot_tags %}

                        <li><a href="#">{{ hot_tag.tags }}</a></li>

                    {% endfor %}
                    </ul>

                </div>
            </div>
        </div>
    </div>
</div>

<div class="container-fluid cl-footer">
    <div class="container">
        <p class="cl-copyright">本设计由简.工作室荣誉出品</p>
        <p class="cl-copyright">copyright @ 2017~2018 简.工作室（www.jeanstudio.cn）</p>
    </div>
</div>

<script src="{% static 'jquery/jquery.min.js' %}"></script>
<script src="{% static 'bootstrap/js/bootstrap.min.js' %}"></script>
<script src="{% static 'highlight/highlight.pack.js' %}"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="{% static 'vue/vue-2.5.16.js' %}"></script>
<script src="{% static 'js/host.js' %}"></script>
<script src="{% static 'js/common.js' %}"></script>
<script src="{% static 'js/index.js' %}"></script>
</body>
</html>